"""Definition of the multiproducts content type
"""

from zope.interface import implements

#from Products.Archetypes import atapi
from Products.ATContentTypes.content import folder
from Products.ATContentTypes.content import schemata

from my315ok.products import productsMessageFactory as _
from my315ok.products.interfaces import Imultiproducts
from my315ok.products.config import PROJECTNAME

try:
    from Products.LinguaPlone import public as atp
except ImportError:
    # No multilingual support
    from Products.Archetypes import atapi as atp


multiproductsSchema = folder.ATFolderSchema.copy() + atp.Schema((

    # -*- Your Archetypes field definitions here ... -*-

    atp.IntegerField(
        'PerPagePrdtNum',
        storage=atp.AnnotationStorage(),
        widget=atp.IntegerWidget(
            label=_(u"numbers per page"),
            description=_(u"product numbers for per page"),
        ),
        required=True,
        default=_(u"3"),
        languageIndependent=True,
        validators=('isInt'),
    ),


))

# Set storage on fields copied from ATFolderSchema, making sure
# they work well with the python bridge properties.

multiproductsSchema['title'].storage = atp.AnnotationStorage()
multiproductsSchema['description'].storage = atp.AnnotationStorage()

schemata.finalizeATCTSchema(
    multiproductsSchema,
    folderish=True,
    moveDiscussion=False
)


class multiproducts(folder.ATFolder):
    """a product that contains multiple product materiales"""
    implements(Imultiproducts)

    meta_type = "multiproducts"
    schema = multiproductsSchema
    _at_rename_after_creation = True

    title = atp.ATFieldProperty('title')
    description = atp.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    PerPagePrdtNum = atp.ATFieldProperty('PerPagePrdtNum')


atp.registerType(multiproducts, PROJECTNAME)
